<template>
	<view class="zai-box">
		<!-- <image src="../../static/zaizai-login/register.png" mode='aspectFit' class="zai-logo"></image> -->
		<view class="zai-title">LOGO区域</view>
		<view class="zai-form">
			<input class="zai-input" v-model="username" placeholder="请输入用户名" />
			<input class="zai-input" v-model="password" password placeholder="请输入密码" />
			<input class="zai-input" v-model="password_s" password placeholder="请再输入一次密码" />
			<button class="zai-btn" @click="register">立即注册</button>
			<navigator url="../zaizai-login/index" open-type='navigateBack' hover-class="none" class="zai-label">
				已有账号，点此去登录.</navigator>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: '',
				password: '',
				password_s: '',
				needPermission: false
			}
		},
		methods: {
			register() {
				if (this.password != this.password_s) {
					this.$http.show('两次输入的密码不一致')
					return
				}
				this.$http.user({
					action: 'register',
					params: {
						username: this.username,
						password: this.password,
						needPermission: this.needPermission
					}
				}).then((res) => {
					console.log(res);
					if (res.code != 0) {
						this.$http.show(res.msg)
					} else {
						// 注册成功,并以生成邀请码
						this.$http.show('注册成功')
						// 返回登录
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					}
					// uni.setStorageSync('user', res)
				}).catch((err) => {
					this.$http.show(err.msg)
				})
			},
		}
	}
</script>

<style>
	.zai-box {
		padding: 0 100upx;
		position: relative;
	}

	.zai-logo {
		width: 100%;
		width: 100%;
		height: 310upx;
	}

	.zai-title {
		position: absolute;
		top: 0;
		line-height: 360upx;
		font-size: 68upx;
		color: #fff;
		text-align: center;
		width: 100%;
		margin-left: -100upx;
	}

	.zai-form {
		margin-top: 300upx;
	}

	.zai-input {
		background: #e2f5fc;
		margin-top: 30upx;
		border-radius: 100upx;
		padding: 20upx 40upx;
		font-size: 36upx;
	}

	.input-placeholder,
	.zai-input {
		color: #94afce;
	}

	.zai-label {
		padding: 60upx 0;
		text-align: center;
		font-size: 30upx;
		color: #a7b6d0;
	}

	.zai-btn {
		background: #ff65a3;
		color: #fff;
		border: 0;
		border-radius: 100upx;
		font-size: 36upx;
		margin-top: 60upx;
	}

	.zai-btn:after {
		border: 0;
	}

	/*按钮点击效果*/
	.zai-btn.button-hover {
		transform: translate(1upx, 1upx);
	}
</style>
